import axios from './axios'

export async function get(url, params) {
    return new Promise((resolve, reject) => {
        axios
            .get(url, params)
            .then(res => {
                resolve(res.data)
            })
            .catch(err => {
                reject({ status: -1, msg: err.errMsg || '请求失败' })
            })
    })
        .then(res => res)
        .catch(err => err)
}

export async function post(url, params) {
    return new Promise((resolve, reject) => {
        axios
            .post(url, params)
            .then(res => {
                resolve(res.data)
            })
            .catch(err => {
                reject({ status: -1, msg: err.errMsg || '请求失败' })
            })
    })
        .then(res => res)
        .catch(err => err)
}

export default {
    get,
    post,
}
